package com.wecan.base.metadata;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Author liuzhihao
 * @Date 2022.01.21
 * @Version ${version}
 * @Description 权限列表,枚举命名规范${P_101010303}
 * type 0 menu
 * type 1 api
 */
public enum Permission {
    // 一级属性
    P_101("小二端权限管理", 101, null, 0),

    // 用户权限
    P_1010104("用户管理", 1010104, 10101, 0),
    P_101010403("用户列表", 101010403, 1010104, 1),
    P_101010402("修改用户", 101010402, 1010104, 1),
    P_101010401("添加用户", 101010401, 1010104, 1),

    // 角色权限
    P_1010103("角色管理", 1010103, 10101, 0),
    P_101010305("所有角色", 101010305, 1010103, 1),
    P_101010304("角色列表", 101010304, 1010103, 1),
    P_101010302("修改角色", 101010302, 1010103, 1),
    P_101010301("添加角色", 101010301, 1010103, 1),
    P_101010303("删除角色", 101010303, 1010103, 1),

    // 基础权限接口
    P_1010102("权限管理", 1010102, 10101, 0),
    P_101010204("权限列表", 101010204, 1010102, 1),

    // 字典权限
    P_1010101("字典管理", 1010101, 10101, 0),
    P_101010101("添加字典", 101010101, 1010101, 1),
    P_101010102("所有字典", 101010102, 1010101, 1),
    P_101010103("修改字典", 101010103, 1010101, 1),
    P_101010104("删除字典", 101010104, 1010101, 1),
    P_101010105("字典分页", 101010105, 1010101, 1),
    P_101010106("添加字典子属性", 101010106, 1010101, 1),
    P_101010107("修改字典子属性接口", 101010107, 1010101, 1),
    P_101010108("删除字典子属性", 101010108, 1010101, 1),

    // 系统设置
    P_10101("系统设置", 10101, 101, 0),

    // banner管理
    P_10102("banner管理", 10102, 101, 0),
    P_1010201("banner列表", 1010201, 10102, 1),
    P_1010202("添加banner", 1010202, 10102, 1),
    P_1010203("编辑banner", 1010203, 10102, 1),
    P_1010204("删除banner", 1010204, 10102, 1),

    // 类目管理
    P_10103("类目管理", 10103, 101, 0),
    P_1010301("类目列表", 1010301, 10103, 1),
    P_1010302("新增类目", 1010302, 10103, 1),
    P_1010303("编辑类目", 1010303, 10103, 1),
    P_1010304("删除类目", 1010304, 10103, 1),

    // 文章管理
    P_10104("文章管理", 10104, 101, 0),
    P_1010401("审核列表", 1010401, 10104, 0),
    P_1010402("文章列表", 1010402, 10104, 0),
    P_1010403("审核文章", 1010403, 10104, 1),
    P_1010404("下线文章", 1010404, 10104, 1),

    // 版本管理
    P_10105("版本管理", 10105, 101, 0),
    P_1010501("版本列表", 1010501, 10105, 1),
    P_1010502("新增版本", 1010502, 10105, 1),
    P_1010503("编辑版本", 1010503, 10105, 1),

    // 关键词管理
    P_10106("搜索关键词管理", 10106, 101, 0),
    P_1010601("关键词列表", 1010601, 10106, 1),
    P_1010602("关键词审核", 1010602, 10106, 1),

    // 任务调度管理
    P_10107("任务调度管理", 10107, 101, 0),
    P_1010701("任务调度列表", 1010701, 10107, 1),
    P_1010702("添加任务", 1010702, 10107, 1),
    P_1010703("编辑任务", 1010703, 10107, 1),
    P_1010704("删除任务", 1010704, 10107, 1),
    P_1010705("立即执行任务", 1010705, 10107, 1),
    P_1010706("暂停任务", 1010706, 10107, 1),
    P_1010707("恢复任务", 1010707, 10107, 1),

    // 评论管理
    P_10108("内容审核", 10108, 101, 0),
    P_1010801("评论列表", 1010801, 10108, 0),
    p_101080101("审批评论", 101080101, 1010801, 1),
    P_1010802("回复列表", 1010802, 10108, 0),
    P_101080201("审批回复", 101080201, 1010802, 1),

    // 优惠券
    P_10109("优惠券管理", 10109, 101, 0),
    P_1010901("优惠券列表", 1010901, 10109, 0),
    P_101090101("优惠券列表", 101090101, 1010901, 1),
    P_101090102("增加优惠券", 101090102, 1010901, 1),
    P_101090103("删除优惠券", 101090103, 1010901, 1),
    P_101090104("增加优惠券数量", 101090104, 1010901, 1),
    P_101090105("减少优惠券数量", 101090105, 1010901, 1),
    // 优惠券运营
    P_1010902("优惠券运营", 1010902, 10109, 0),
    P_101090201("优惠券运营页面列表", 101090201, 1010902, 1),
    P_101090202("新增优惠券运营页面", 101090202, 1010902, 1),
    P_101090203("更新优惠券运营页面", 101090203, 1010902, 1),
    P_101090204("更新运营页面状态", 101090204, 1010902, 1),
    P_101090205("删除优惠券运营页面", 101090205, 1010902, 1),

    // 财务管理
    P_10110("财务管理", 10110, 101, 0),
    P_1011001("平台收入", 1011001, 10110, 0),
    P_101100101("平台收入列表", 101100101, 1011001, 1),
    P_1011002("平台积分记录", 1011002, 10110, 0),
    P_1011003("提现申请", 1011003, 10110, 0),
    P_101100301("提现列表", 101100301, 1011003, 1),
    P_101100302("提现操作", 101100302, 1011003, 1),
    P_1011004("用户现金排行榜", 1011004, 10110, 0),
    P_101100401("用户现金排行榜列表", 101100401, 1011004, 1),
    P_1011005("用户积分排行榜", 1011005, 10110, 0),
    P_101100501("用户积分排行榜", 101100501, 1011005, 1),
    P_1011006("最热付费文章排行榜", 1011006, 10110, 0),
    P_101100601("最热付费文章排行榜列表", 101100601, 1011006, 1),

    // 数据分析
    P_10111("数据分析", 10111, 101, 0),
    P_1011101("平台数据统计", 1011101, 10111, 0),
    P_1011102("平台运营统计", 1011102, 10111, 0),

    // 用户管理
    P_10112("用户管理", 10112, 101, 0),
    P_1011201("用户反馈", 1011201, 10112, 0),
    P_101120101("反馈列表", 101120101, 1011201, 1),
    P_101120102("处理反馈", 101120102, 1011201, 1),
    P_1011202("头像认证", 1011202, 10112, 0),
    P_101120201("头像认证列表", 101120201, 1011202, 1),
    P_101120202("头像认证审核", 101120202, 1011202, 1),
    P_1011203("用户举报", 1011203, 10112, 0),
    P_101120301("举报列表", 101120301, 1011203, 1),
    P_101120302("举报处理", 101120302, 1011203, 1);

    private final String name;

    private final int mark;

    private final Integer parentMark;

    private final int type;

    Permission(String name, int mark, Integer parentMark, int type) {
        this.name = name;
        this.mark = mark;
        this.parentMark = parentMark;
        this.type = type;
    }

    public int getMark() {
        return mark;
    }

    public Integer getParentMark() {
        return parentMark;
    }

    public int getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    @JsonValue
    public JSONObject getValue() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("mark", mark);
        jsonObject.put("parentMark", parentMark);
        jsonObject.put("name", name);
        jsonObject.put("type", type);
        return jsonObject;
    }
}
